package com.ilancuo.java8;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;

public class StreamTest2 {
    public static void main(String[] args) {
//        test();
        testParallel();
    }

    private static void test() {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 2048; i++) {
            list.add(i);
        }

        list
                .stream()
                .filter(n -> (n & 0x1) == 0)
                .forEach(System.out::println);
    }

    private static void testParallel() {
        IntStream.range(1, 2048)
                .parallel()
                .filter(n -> (n & 0x1) == 0) //过滤所有的偶数
                .forEach(System.out::println);
    }
}
